package cn.dansj.handler.interfaces;

import cn.dansj.annotation.MarkAsApi;
import cn.dansj.common.utils.transfer.Transformation;
import cn.dansj.configure.EncryptAndDecrypt;
import cn.dansj.handler.InterfaceHandler;

import java.util.Map;

@MarkAsApi
public class GetPublicKey extends InterfaceHandler {

    private final EncryptAndDecrypt encryptAndDecrypt;

    public GetPublicKey(EncryptAndDecrypt encryptAndDecrypt) {
        this.encryptAndDecrypt = encryptAndDecrypt;
    }

    @Override
    public Object execute(Map<String, Object> paramsMap) {
        return Transformation.lambdaTryCatch(() -> encryptAndDecrypt.getKeyPem().publicKey(), () -> null);
    }
}
